`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: CBICR, Tsinghua Univ.
// Engineer: Hongyi Li
// 
// Create Date: 2025/01/07 19:33:10
// Design Name: 
// Module Name: Look-Ahead Conflict Check
// Project Name: 
// Target Devices: 
// Tool Versions: 
// Description: 
// 
// Dependencies: 
// 
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
// 
//////////////////////////////////////////////////////////////////////////////////

module LkAheadConflict
#(
    parameter DataWidth = 'd32,
    parameter LkAheadWidth = 'd14
)(
    input                     clk,
    input                     rst_n,
    input  [LkAheadWidth-1:0] i_lookahead_e,
    input  [LkAheadWidth-1:0] i_lookahead_w,
    input  [LkAheadWidth-1:0] i_lookahead_n,
    input  [LkAheadWidth-1:0] i_lookahead_s,
    input  [LkAheadWidth-1:0] i_lookahead_l,
    output [5           -1:0] o_bypass
);

reg [4:0] reg_bypass;

// Naive LA-CC
always @(posedge clk) begin
    if (~rst_n) begin
        reg_bypass <= 0;
    end else begin
        reg_bypass[0] <= | i_lookahead_e;
        reg_bypass[1] <= | i_lookahead_w;
        reg_bypass[2] <= | i_lookahead_n;
        reg_bypass[3] <= | i_lookahead_s;
        reg_bypass[4] <= | i_lookahead_l;
    end
end

assign o_bypass = reg_bypass;

endmodule